from PyQt5.QtWidgets import QApplication,QWidget,QLabel,QPushButton,QGridLayout
import sys

class Window(QWidget):

    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        # 创建4个按钮
        btn1 = QPushButton('1')
        btn2 = QPushButton('2')
        btn3 = QPushButton('3')
        btn4 = QPushButton('4')

        # 创建表格布局
        grid = QGridLayout()
        # 将按钮添加到布局中
        grid.addWidget(btn1,1,1)
        grid.addWidget(btn2,1,2)
        grid.addWidget(btn3,2,1)
        grid.addWidget(btn4,2,2)

        self.setLayout(grid)
        self.setGeometry(1000,300,300,200)
        self.setWindowTitle('绝对定位')
        self.show()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    w = Window()
    app.exec()